<template>
	<div id="goodsCode">
		<!--<haders title="我的商品二维码"></haders>-->
		<div class="neirong">
			<p class="hd">
				<i>
					<img :src="items.GoodsImg" />
				</i>
				<span class="hd_text">{{items.GoodsName}}</span>
			</p>
			<p class="ct"><img :src="imgUrl"></p>
			<p class="ft">扫一扫，支付并开团</p>
		</div>
	</div>
</template>
<script>
	import { Indicator } from 'mint-ui';
	import { Toast } from 'mint-ui';
	export default {
		name: 'goodsCode',
		components: {

		},
		data() {
			return {
				imgUrl:'',
				items:[]
			}
		},
		created() {
			this.imgError = this.$store.state.imgError;
			this.urls= this.$store.state.urls;
			this.shopId=this.$store.state.shopId;//获取店铺ID
		},
		mounted() {
			this.GoodsId=this.$route.params.GoodsId; 
			this.shopId=this.$route.params.shopId; 
			this.imgUrl=this.urls+'/Common/Qr?qrType=3&id='+this.GoodsId+'&sid='+this.shopId
			this.getGoodsDetails();
		},
		methods: {
			 getGoodsDetails() {
				let _this = this;
				if(_this.GoodsId) {
					Indicator.open({
						text: '初始化中...'
					});
					_this.$http.get("/ManagerGroupBuy/GetManageGoodsDetails", {
						params: {
							"goodsId": _this.GoodsId
						}
					}).then((res) => {
						console.log(res);
						if(res.data.code == 1) {
							_this.items = res.data.data;
							_this.WXstare(res.data.data);
							Indicator.close();
						} else {
							Toast(res.data.msg);
							Indicator.close();
						} 
					}).catch((err) => {
						Toast(err);
						console.log(err)
					}); 
				}
		},
		//分享商品
			WXstare(items){ 
				console.log(items)
				let urls='/clientele/goodsDetails/'+items.Id+'?shopID='+this.shopId;
				let param={
		            title: items.GoodsName, // 分享标题
		            desc:items.GoodsAbout,// 分享描述
		            link:urls, // 分享链接
		            imgUrl:items.GoodsImg, // 分享图标
		            success: function (res) {
		              // 用户确认分享后执行的回调函数
		              window.alert("已经分享成功！")
		            },
		            cancel: function (res) {
		              // 用户取消分享后执行的回调函数
		               window.alert("分享失败！")
		            }
				} 
				this.wxShare(1,param); 
				
			}
	}
}
</script>
<style scoped>
	.neirong {
		width: 100%;
		padding: 0 0.5rem;
		background-color: #fff;
		text-align: center;
	}
	
	.neirong .hd {
		color: #333333; 
		padding: 0.5rem 0;
		text-align: initial;
		overflow: hidden;
		
	}
	.neirong .hd i{
		width: 20%;
		margin-right: 5%;
		display: inline-block;
		float: left;
	}
	.neirong .hd i img{
		width: 100%;
	}
	.neirong .hd span{
		float: left;
		display: inline-block;
		width: 75%;  
		font-size: 0.373333rem;
		color: #333333;
		margin-top: 0.3rem;
	}
	
	.neirong .ft {
		font-size: 0.373333rem;
		color: #666;
		padding: 0.5rem 0;
	}
	
	.neirong .ct img {
		width: 70%;
	}
</style>